package bjx.com.kehu.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import bjx.com.kehu.R;

/**
 * Created by jqc on 2017/11/14.
 */

public class AddNoteActivity extends BaseActivity {

    ImageView mIVBack;
    TextView mTVTitle;
    TextView mTVEvent;

    EditText mETNote;

    @Override
    protected void initView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_addnote);
        mIVBack = getViewById(R.id.back);
        mTVTitle = getViewById(R.id.title);
        mTVTitle.setText("写备注");
        mTVEvent = getViewById(R.id.event);
        mTVEvent.setText("提交");
        mTVEvent.setVisibility(View.VISIBLE);

        mETNote = getViewById(R.id.addnote_et_note);
    }

    @Override
    protected void setListener() {
        mIVBack.setOnClickListener(this);
        mTVEvent.setOnClickListener(this);
    }

    @Override
    protected void processLogic(Bundle savedInstanceState) {
        mETNote.setText(getIntent().getStringExtra("note"));
        mETNote.setSelection(mETNote.length());
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.event: // 提交
                String note = mETNote.getText().toString().trim();
                setResult(200, new Intent().putExtra("note", note));
                finish();
                break;
            case R.id.back:
                finish();
                break;
            default:break;
        }
    }
}
